<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
if($_SERVER["REMOTE_ADDR"] != "218.32.210.153" && $_SERVER["REMOTE_ADDR"] != "218.32.210.156" && $_SERVER["REMOTE_ADDR"] != "59.120.49.178"){
	print ":p => ".$_SERVER["REMOTE_ADDR"];
	exit();
}
$arrCon = file("http://192.168.5.200/test/makeMD5String.php");
$_DBSite = "Master";
include_once($_SERVER["DOCUMENT_ROOT"]."/modules/mysql_wrappers.lib.php");
global $_Conn;
switch($_DBSite){
	case "Result":	//結帳資料庫
		$_BetDBHost = "192.168.5.120";
		$_Conn = "_ConnResult";
		global $_ConnResult;
		break;
	
	case "History":
	case "Query":	//查詢資料庫
		$_BetDBHost = "192.168.5.120";
		$_Conn = "_ConnQuery";
		global $_ConnQuery;
		break;

	case "Master":	 //主資料庫
	default:	 //預設
		$_BetDBHost = "192.168.5.120";
		$_Conn = "_ConnMaster";
		global $_ConnMaster;
		break;
}

$_BetDBUser = "kacino";
$_BetDBPass = "cyriac_0426";
$_BetDBName = "betLottoSample";
$_BetWeb = "sample.luckyball.us";

if (! $$_Conn = @mysql_connect($_BetDBHost, $_BetDBUser, $_BetDBPass)) {
	?>
	系統維護中，請稍候再登入！不便之處，敬請見諒！！
	<!--系統維護中, 請<a href="javascript:location.reload();">重新整理</a><P>//-->
	<?php
	$email = "service@".$_BetWeb;
	$subject = " mysql_connect error (".$_BetWeb.")";
	$content = "連線錯誤：無法連線至資料庫主機！\nDBSite".$_DBSite."\nPage: ".$_SERVER["PHP_SELF"]."\n";
	mail($email, $subject, $content, "From:".$_BetWeb."<apache@secure.".$_BetWeb.">");
	exit();
}

if (! @PMA_mysql_select_db($_BetDBName, $$_Conn)) {
	?>
	系統維護中，請稍候再登入！不便之處，敬請見諒！
	<!--系統忙碌中, 請稍候片刻, 或立即<a href="javascript:location.reload();">重新整理</a>.//-->
	<script>
	function abc() {
		location.reload();
	}
	setInterval(abc,60000);
	</script>
	<?php 
	$email = "service@".$_BetWeb;
	$subject = "mysql_select_db error (".$_BetWeb.")";
	$content = "連線錯誤：無法連結資料庫！\nDBSite".$_DBSite."\nPage: ".$_SERVER["PHP_SELF"]."\n".PMA_mysql_error($$_Conn);
	$content .= "\nAccount=".$_SESSION["MemberInfo"] -> Account;
	mail($email, $subject, $content, "From:".$_BetWeb."<apache@secure.".$_BetWeb.">");
	exit();
}


include_once($_SERVER["DOCUMENT_ROOT"]."/getvars.inc.php");
include_once($_SERVER["DOCUMENT_ROOT"]."/modules/Tool.lib.php");
if(trim($arrCon[0]) !== trim($_data["CK"])){
	print "^_^|||";
	exit();
}

$arrSQL = split(";;;", stripslashes($_data["strSQL"]));

if(!is_array($arrSQL)){
	print "No SQL Command!!";
	exit();
}

foreach($arrSQL as $strSQL){
	if(preg_match("/bet_Marquee/", $strSQL)){
		if(preg_match("/insert/", $strSQL))continue;
	}
	if(!mysql_query($strSQL, $_ConnMaster)){
		print "SQL: ".$strSQL."<br>\n";
		print "Error: ".mysql_error($_ConnMaster)."<br>\n";
	}
}
if(preg_match("/bet_SystemParam/", $_data["strSQL"])){
	if(!makeSystemParamFile()){
		print $GLOBALS["errormessage"]."<br>\n";
		print $GLOBALS["errorhidden"]."<br>\n";
	}
}
?>OK